<%@ page language="java" contentType="text/html; charset=utf-8"%>
<%@ include file="/commons/taglibs.jsp"%>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>新增住房信息</title>
<link href="${ctx}/styles/public.css" rel="stylesheet" type="text/css">
<link href="${ctx}/styles/listTable.css" rel="stylesheet" type="text/css">
<link href="${ctx}/styles/aux_window.css" rel="stylesheet" type="text/css">
<link href="${ctx}/styles/validation/style.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="${ctx}/scripts/common/prototype.js"></script>
<script language="JavaScript" type="text/javascript" src="${ctx}/scripts/validation/validation.js"></script>
<script language="JavaScript" type="text/javascript" src="${ctx}/scripts/div/common.js"></script>
<script language="JavaScript" type="text/javascript" src="${ctx}/scripts/common.js"></script>
<script language="JavaScript" type="text/javascript" src="${ctx}/scripts/public.js"></script>
<script language="JavaScript" type="text/javascript" src="${ctx}/scripts/ajaxException.js"></script>
<script language="JavaScript" type="text/javascript" src="${ctx}/pages/com/ce/pms/customer/tenement.js"></script>
<style type="text/css">
.inputHidden {
BORDER-RIGHT: medium none; BORDER-TOP: medium none; FONT-SIZE: 12px; BORDER-LEFT: medium none; WIDTH: 99%; COLOR: #000000; BORDER-BOTTOM: medium none; FONT-FAMILY: "宋体"; HEIGHT: 100%; TEXT-DECORATION: none
}
</style>
<script>
var house = null;  //房屋相关操作对象
var closeFlag = false;  //标识点击并新增、保存按钮
function choiceHouse(){
	var url = "${ctx}/customer_chooseSingleHouseAction.do?method=chooseBuildingMain&isOwnerName=withOwnerName";
	top.windowOpen(url, "choiceHouse", "", 500, 800);
}
function setHouseInfo(houseId,houseNum,customerName){
		document.getElementById("houseId").value = houseId;
		document.getElementById("houseNumber").value = houseNum;
		document.getElementById('ownerName').value = customerName;
		$('houseNumber').fireEvent("onblur");
}
function ajaxSubmit(formId){
		var isTrue=$(formId).fireEvent("onSubmit");
	    if(isTrue){
         var url = document.getElementById(formId).action;
         var param = Form.serialize(formId);
         new Ajax.Request(url,{method: 'post',parameters :param ,onComplete : closeFrm});
		}
}

function ajaxSearchHouse()
{
	var url = "${ctx}/customer_customerAction.do?method=queryCustomerHouse";
	var houseNumber = $F('houseNumber');
	if(houseNumber == "")
		return;
	var param = "houseNumber="+houseNumber;
	new Ajax.Request(
                    url,
                    {method: 'post', parameters: param, onComplete: showResponse}
                    );
}
function showResponse(result){
	var obj=eval('(' + result.responseText + ')');
	$('houseId').value=obj.houseId;
	$('ownerName').value=obj.ownerName;
}
function processHouseNumber(obj){
  house.validateHouseNum(obj.value, ajaxSearchHouse);
  if($('houseNumber').value==''){
		$('ownerName').value='';
		$('houseId').value='';
  }

}
function setCloseFlag(flag){
	closeFlag = flag;
}
function closeFrm(response){
	ajaxSubmitException(response.responseText);
	if('true' == response.responseText){
    	var frameid=findFrame('connTabPanel');
    	frameid.refreshLesseeHouseList();
    	 if(!closeFlag){ //点击的保存按钮
	        windowClose();
		}
		else {  //点击的保存并新增
	        location.reload();
		}
    }

}
function init(){
	tenementFlag ="lessee";
	house = new House('houseNumber');
}
function setlesseeName(){

	$('houseNumber').fireEvent("onblur");
}
</script>
</head>

<body onload="init()">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td class="window_head_outBg"><table border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td><img src="${ctx}/images/ico_Advance.gif" width="16" height="16" align="absmiddle"> <span class="window_head_intext">新增住房信息</span></td>
        </tr>
    </table></td>
  </tr>
  <tr>
    <td class="aux_header_line_1"></td>
  </tr>
  <tr>
    <td class="aux_header_line_2"></td>
  </tr>
  <tr>
    <td class="content"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td class="aux_outtable_color">
        <form name="lesseeHouseForm" method="post" action="${ctx}/customer_lesseeAction.do?method=addLesseeHouseCache" class="required-validate">
        <input type="hidden" name="houseId" value=""/>
        <table width="100%" border="0" cellpadding="0" cellspacing="1" class="aux_intable_color">
            <tr>
              <td class="aux_intable_td1">房号：</td>
              <td class="aux_intable_require"><table border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td><input name="houseNumber"  type="text" class="required" onblur="processHouseNumber(this);" value=""   size="16" afterInsert="bdAfter" maxlength="36"></td>
                    <td width="4">&nbsp;</td>
                    <td><a href="#"  onClick="choiceHouse();"onFocus="this.blur()"><img src="${ctx}/images/ico_houesno.GIF" alt="请点选查找房号" border="0"></a><span id="bdAfter"></span></td>
                  </tr>
              </table></td>
            </tr>
            <tr>
              <td class="aux_intable_td1">业主姓名：</td>
              <td class="aux_intable_td2"><input name="ownerName" type="text" class="inputHidden" readonly="true"  size="16" /></td>
            </tr>
        </table>
        </form>
        </td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td class="window_footer"><table border="0" cellpadding="0" cellspacing="0">
      <tr><!--
        <td><table border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td class="buttonOffLeft" id="btn1_41"></td>
              <td class="buttonOffMiddle" id="btn1_42" onClick="setCloseFlag(true);ajaxSubmit('lesseeHouseForm');" onMouseOver="btn_change_over(4)" onMouseOut="btn_change_out(4)" onblur="btn_change(4)"><img src="${ctx}/images/ico_htn_interim.gif" alt="" width="14" height="15" border="0" align="absbottom">&nbsp;保存并新增</td>
              <td class="buttonOffRight" id="btn1_43"></td>
            </tr>
        </table></td>
        <td class="btn_between_space"></td>-->
        <td><table border="0" cellpadding="0" cellspacing="0" >
            <tr>
              <td class="buttonOffLeft" id="btn1_51"></td>
              <td class="buttonOffMiddle" id="btn1_52" onblur="btn_change(5)" onMouseOver="btn_change_over(5);setlesseeName()" onMouseOut="btn_change_out(5)" onClick="setCloseFlag(false);ajaxSubmit('lesseeHouseForm')"><img src="${ctx}/images/ico_ok.gif" border="0" align="absmiddle" /> 保 存</td>
              <td class="buttonOffRight" id="btn1_53"></td>
            </tr>
        </table></td>
        <td class="btn_between_space"></td>
        <td><table border="0" cellpadding="0" cellspacing="0" onClick="">
            <tr>
              <td class="buttonOffLeft" id="btn1_31"></td>
              <td class="buttonOffMiddle" id="btn1_32" onblur="btn_change(3)" onMouseOver="btn_change_over(3)" onMouseOut="btn_change_out(3)" onClick="windowClose();"><img src="${ctx}/images/ico_cancel.gif" border="0" align="absmiddle" /> 关 闭</td>
              <td class="buttonOffRight" id="btn1_33"></td>
            </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
</table>
</body>
</html>